package com.zhangxu.microservice.employee.domain.mapstrcut;

import com.zhangxu.microservice.employee.common.enums.GenderEnum;
import com.zhangxu.microservice.employee.dao.entity.EmployeeDO;
import com.zhangxu.microservice.employee.domain.dto.CreateEmployeeDTO;
import com.zhangxu.microservice.employee.domain.dto.EmployeeDTO;
import org.mapstruct.Mapper;

import java.util.Optional;

@Mapper(componentModel = "spring")
public interface EmployeeDomainConverter {

    EmployeeDO toEmployeeDO(CreateEmployeeDTO createUserDTO);

    EmployeeDTO toEmployeeDTO(EmployeeDO userDO);

    default String genderEnum2String(GenderEnum genderEnum) {
        return Optional.ofNullable(genderEnum).map(GenderEnum::name).orElse(null);
    }

    default GenderEnum string2GenderEnum(String gender) {
        return Optional.ofNullable(gender).map(GenderEnum::valueOf).orElse(null);
    }

}
